﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;

[Hotfix]
public class TestHotFix : MonoBehaviour
{
    LuaEnv luaEnv = null;
    private GameObject cube;

    private void Awake()
    {
        Init();
    }

    public void Init()
    {
        cube = GameObject.Find("Cube");
    }

    private void Start()
    {
        Debug.Log("Add:"+Add(1, 3));
        Debug.Log(Add(new Vector3(1, 1, 1), new Vector3(2, 2, 2)));

        luaEnv = new LuaEnv();
        luaEnv.DoString("require 'hotfix'");
        Debug.Log("Add:" + Add(1, 3));
        Debug.Log(Add(new Vector3(1, 1, 1), new Vector3(2, 2, 2)));


        //luaEnv.Dispose();
    }

    public void ChangeCubeArgs()
    {
        Init();
        cube.transform.localEulerAngles = new Vector3(0, 30, 0);
        cube.GetComponent<MeshRenderer>().material.color = Color.red;
    }

    private int Add(int a, int b)
    {
        return a - b;
    }

    private Vector3 Add(Vector3 a, Vector3 b)
    {
        return a - b;
    }
}
